<?php
include('Provider.class.php');
//include('Config.class.php');
class UserDAO extends Provider {

	function UserDAO () {
		echo 'before connect';
        $this->connectToDb();
        echo 'after connect';
		$this->getUserByID(1);
    }
	function getUserByID($id)
	{
        $queryString =  'SELECT * FROM USER WHERE id = '.(string)$id.' LIMIT 0, 1 ';
		$result = mysql_query($queryString);
     
        echo $queryString;
		if (!$result) {
			die('Invalid query: ' . mysql_error());
		}
		while ($row = mysql_fetch_assoc($result)) {
            echo " => ";
			echo $row['username'];
            
			return new UserDTO($row['id'],$row['username'],$row['password'],$row['email'],$row['sex'],$row['role']);
		}
	}
	
}
?>